﻿@{
    ViewBag.Title = "信息模块";
    Layout = "~/Views/Shared/_Index.cshtml";
}
<script>
    $(function() {

        gridList();
    });

    function gridList() {
        var $gridList = $("#gridList");
        var postData = {
            keyword: ""
        };
        $gridList.dataGrid({
            url: "/InformationCenter/News/GetGridJsonWX",
            postData: postData,
            height: $(window).height() - 128,
            multiselect: true,
            colModel: [
                { label: '主键', name: 'F_Id', hidden: true },
                { label: '标题', width: 200, name: 'F_Title', align: 'left' }
                ,
                {
                    label: '访问地址',
                    name: 'F_Id',
                    align: 'left'
                }
                //,
                //{
                //    label: '类型',
                //    name: 'F_TypeId',
                //    align: 'center',
                //    width: 100,
                //    formatter: function (cellvalue) {
                //        return cellvalue == 0 ? '常规' : cellvalue == 1 ? '置顶' : '系统';
                //    }
                //}
            ],
            pager: "#gridPager",
            sortname: 'F_CreatorTime desc',
            viewrecords: true
        });
        $("#btn_search").click(function() {
            $gridList.jqGrid('setGridParam',
            {
                postData: { keyword: $("#txt_keyword").val() }
            }).trigger('reloadGrid');
        });
    }

    function btn_add() {
        $.modalOpen({
            id: "Form",
            title: "添加信息",
            url: "/InformationCenter/News/Form",
            width: "950px",
            height: "710px",
            callBack: function(iframeId) {
                top.frames[iframeId].submitForm();
            }
        });
    }

    function btn_edit() {
        var rows = $("#gridList").jqGridRowValue();
        if (rows.length > 0) {
            var keyValue = rows[rows.length - 1].F_Id;
            $.modalOpen({
                id: "Form",
                title: "修改信息",
                url: "/InformationCenter/News/Form?keyValue=" + keyValue,
                width: "950px",
                height: "710px",
                callBack: function(iframeId) {
                    top.frames[iframeId].submitForm();
                }
            });
        } else {
            $.modalAlert("请先选择需要修改的信息！", "error");
        }
    }

    function btn_delete() {
        var rows = $("#gridList").jqGridRowValue();
        var ids = $.map(rows,
            function(item, idx) {
                return item.F_Id;
            }).join(',');
        if (ids.length > 0) {
            $.deleteForm({
                prompt: "注：您确定要【删除】选定项信息吗？",
                url: "/InformationCenter/News/DeleteForm",
                param: { keyValues: ids },
                success: function() {
                    $("#gridList").trigger("reloadGrid");
                    $(".toolbar .operate").find('.close').click();
                }
            });
        } else {
            $.modalAlert("请先选择需要删除的信息！", "error");
        }
    }

    function btn_details() {
        var rows = $("#gridList").jqGridRowValue();
        if (rows.length > 0) {
            var keyValue = rows[rows.length - 1].F_Id;
            $.modalOpen({
                id: "Details",
                title: "查看信息",
                url: "/InformationCenter/News/Details?keyValue=" + keyValue,
                width: "950px",
                height: "710px",
                btn: null
            });
        } else {
            $.modalAlert("请先选择需要查看的信息！", "error");
        }
    }

    function getSelectIds() {
        var rows = $("#gridList").jqGridRowValue();
        var ids = $.map(rows,
            function(item, idx) {
                return "'" + item.F_Id + "'";
            }).join(',');
        return ids;
    }
</script>

<div class="topPanel">
    <div class="search">
        <table>
            <tr>
                <td>
                    <div class="input-group">
                        @*<input id="txt_keyword" type="text" class="form-control" placeholder="信息标题" style="width: 200px;">
                        <span class="input-group-btn">
                            <button id="btn_search" type="button" class="btn  btn-primary">
                                <i class="fa fa-search"></i>
                            </button>
                        </span>*@
                    </div>
                </td>
            </tr>
        </table>
    </div>
    <div class="toolbar">
        <div class="btn-group">
            <a class="btn btn-primary" onclick="$.reload()">
                <span class="glyphicon glyphicon-refresh"></span>
            </a>
        </div>
        <div class="btn-group">
            @*<a id="NF-add" authorize="yes" class="btn btn-primary dropdown-text" onclick="btn_add()"><i class="fa fa-plus"></i>添加信息</a>*@
        </div>
        <div class="operate">
            @*<ul class="nav nav-pills">
                <li class="first">已选中<span>1</span>项</li>
                <li>
                    <a id="NF-edit" authorize="yes" onclick="btn_edit()"><i class="fa fa-pencil-square-o"></i>修改信息</a>
                </li>
                <li>
                    <a id="NF-delete" authorize="yes" onclick="btn_delete()"><i class="fa fa-trash-o"></i>删除信息</a>
                </li>
                <li>
                    <a id="NF-Details" authorize="yes" onclick="btn_details()"><i class="fa fa-search-plus"></i>查看信息</a>
                </li>
            </ul>*@
            <a href="javascript:;" class="close"></a>
        </div>
    </div>

</div>
<div class="gridPanel">
    <table id="gridList"></table>
    <div id="gridPager"></div>
</div>